    myApp.factory('paperTemplateService', ['$http', '$q', '$rootScope', function ($http, $q, $rootScope) {
        var paperTemplateService = {};   // 返回的服务
        var apiUrl = $rootScope.url + '/api/web/paper';
        var that = this; // 获取当前作用域，下面要用到
        var defered = $q.defer();
        var postCfg = {
            headers: {'Content-Type': 'application/x-www-form-urlencoded'},
            transformRequest: function (data) {
                return $.param(data);
            }
        };

        var url=$rootScope.urlZ;

        paperTemplateService.paperCategoryTree = function () {
            return $http.get(apiUrl+'/category/tree');
        };


        paperTemplateService.poolGroup = function () {
            return $http.get(apiUrl+'/pool-group')
        }

        paperTemplateService.savePaper = function(data){
            return $http.post(apiUrl+'/save',data,postCfg);
        };

        paperTemplateService.findQuestionByPaper = function (paperId) {
            return $http.get(apiUrl+'/'+paperId+"/question/list");
        }

        paperTemplateService.generate = function(data){
            return $http.post(apiUrl+'/question/generate',data,postCfg);
        };

        return paperTemplateService;

    }]);
